home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
lang_c
/
msqc25t1
/
popup.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-09-29
|
3KB
|
105 lines
/* popup.c: Pop-up window library */
#include <stdio.h>
#include <dos.h>
#include <string.h>
#include <graph.h>
#include "textscrn.h"
#include "popup.h"
void popShow (POPUP *pop) /* display popup window */
{
_setbordwindow (pop->top, pop->left, /* create popup */
pop->bottom, pop->right,
pop->style, pop->normal, pop->normback);
_wrapon (_GWRAPOFF); /* disable text wrap */
if (pop->text != NULL)
_outtext (pop->text); /* write fixed text */
}
void popKeep (POPUP *win) /* preserve state of a window */
{
win->lastcol = wherex();
win->lastrow = wherey();
}
void popUse (POPUP *win) /* re-anable existing window */
{
_settextwindow (win->top, win->left, win->bottom, win->right);
_settextcolor (win->normal);
_setbkcolor (win->normback);
if (win->lastrow > 0)
_settextposition (win->lastrow, win->lastcol);
}
void popCenter (POPUP *win, int row, char *string)
{ /* Center string in window */
int i, tab;
popUse (win);
tab = 1 + (win->right - win->left - strlen (string) + 1) /
2; _settextposition (row, tab);
_outtext (string);
}
void popRewrite (POPUP *win, int row, int fgcolor, int bgcolor)
{ /* Rewrite pop-up row with new colors */
int p, nchars, page, attrib;
union REGS reg;
popUse (win);
page = _setactivepage (0); /* which page? */
_setactivepage (page);
nchars = win->right - win->left + 1; /* popup width */
attrib = (bgcolor << 4) - fgcolor; /* new text attrib */
for (p = 1; p <= nchars; p++) {
_settextposition (row, p);
reg.h.ah = 8; /* get character */
reg.h.bh = page; /* in active page */
int86 (0x10, ®, ®); /* via ROM BIOS */
reg.h.ah = 9; /* write back out with */
reg.h.bl = attrib; /* hilite attribs */
reg.h.bh = page;
reg.x.cx = 1; /* one char */
int86 (0x10, ®, ®);
}
}
void popHilite (POPUP *win, int row)
/* Hilight text in popup row */
{
popRewrite (win, row, win->hilite, win->hiback);
}
void popNormal (POPUP *win, int row)
/* Set text in popup row to normal attribs */
{
popRewrite (win, row, win->normal, win->normback);
}
void menubar (MENUBAR *spec)
/* Write the menu bar described by spec */
{
int fore, back, p, s, row, col, c = 0;
fore = _settextcolor (spec->fore); /* get/set colors */
back = _setbkcolor (spec->back);
row = wherey(); /* get cursor position */
col = wherex();
_settextposition (spec->row, 1); /* start of menu bar */
for (s = 1; s < maxcol(); s++)
_outch (' '); /* set bar background */
_settextposition (wherey(), 1); /* start text to bar */
for (p =0; spec->choice [p]; p++) /* copy text to bar */
if (spec->choice [p] != '\n')
_outch (spec->choice [p]); /* write char */
else /* else move to next menu item */
_settextposition (wherey(), spec->interval * ++c);
/* Restore previous state */
_settextcolor (fore); /* color scheme */
_setbkcolor (back);
_settextposition (row, col); /* cursor position */
}